package com.dandelion.manager.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dandelion.commons.annotation.SystemLog;
import com.dandelion.commons.constants.BaseConst;
import com.dandelion.commons.web.controller.BaseController;
import com.dandelion.commons.web.model.AjaxResponse;
import com.dandelion.manager.system.domain.User;
import com.dandelion.manager.system.service.UserService;

@Controller
@RequestMapping("/manager")
public class MainController extends BaseController {
	
	@Autowired
	public UserService userService ;
	
	/**
	 * 登录页面
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/login", method=RequestMethod.GET)
	public String login(HttpServletRequest request) {
		return viewName("login") ;
	}
	
	/**
	 * 管理主页
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/main", method=RequestMethod.GET)
	public String main(HttpServletRequest request) {
		return viewName("main") ;
	}
	
	/**
	 * 管理主页的仪表盘
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/dashboard", method=RequestMethod.GET)
	public String dashboard(HttpServletRequest request) {
		return viewName("main/dashboard") ;
	}
	
	/**
	 * 我的信息窗口
	 * @return
	 */
	@RequestMapping(value="/myInfoDialog", method=RequestMethod.GET)
	public String myinfo() {
		return viewName("main/myInfo") ;
	}
	
	/**
	 * 修改登录密码窗口
	 * @return
	 */
	@RequestMapping(value="/changePasswordDialog", method=RequestMethod.GET)
	public String changePasswordDialog() {
		return viewName("main/changePasswordDialog") ;
	}
	
	@SystemLog(module=BaseConst.MODULE_SYSTEM+"[系统管理]", method="修改个人登录密码")
	@RequestMapping(value="/changePassword", method=RequestMethod.POST)
	public @ResponseBody AjaxResponse changePassword(User dto) {
		return this.userService.changePassword(dto) ;
	}
	
	/**
	 * 发送邮件窗口
	 * @return
	 */
	@RequestMapping(value="/sendMailDialog", method=RequestMethod.GET)
	public String sendmail() {
		return viewName("main/sendMail") ;
	}
	
}
